-
Notifications
You must be signed in to change notification settings - Fork 40
Add getScanner() method to transaction interfaces #2698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getScanner() method to transaction interfaces #2698
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new getScanner(Scan) method to the transaction CRUD interfaces, provides a base scanner implementation, and wires up stub or delegated implementations throughout the core and service layers.
- Extended
CrudOperable,TransactionCrudOperable, andTransactionManagerCrudOperablewithgetScanner(Scan)and a nestedScannerinterface. - Added
AbstractCrudOperableScanner(and two specialized subclasses) to provide a reusable iterator-based scanner implementation. - Implemented stub or delegated
getScanneroverrides across transaction, manager, and service classes; added placeholder integration tests.
Reviewed Changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/java/com/scalar/db/transaction/consensuscommit/TwoPhaseConsensusCommit.java | Added stub getScanner method |
| core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitManager.java | Added stub getScanner method |
| core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommit.java | Added stub getScanner method |
| core/src/main/java/com/scalar/db/service/TwoPhaseCommitTransactionService.java | Delegated getScanner to manager; updated deprecations |
| core/src/main/java/com/scalar/db/service/TransactionService.java | Delegated getScanner to manager; updated deprecations |
| core/src/main/java/com/scalar/db/common/StateManagedTwoPhaseCommitTransactionManager.java | Added active-check + delegate getScanner |
| core/src/main/java/com/scalar/db/common/StateManagedDistributedTransactionManager.java | Added active-check + delegate getScanner |
| core/src/main/java/com/scalar/db/common/DecoratedTwoPhaseCommitTransactionManager.java | Delegated getScanner |
| core/src/main/java/com/scalar/db/common/DecoratedTwoPhaseCommitTransaction.java | Delegated getScanner |
| core/src/main/java/com/scalar/db/common/DecoratedDistributedTransactionManager.java | Delegated getScanner |
| core/src/main/java/com/scalar/db/common/DecoratedDistributedTransaction.java | Delegated getScanner |
| core/src/main/java/com/scalar/db/common/ActiveTransactionManagedTwoPhaseCommitTransactionManager.java | Synchronized override getScanner |
| core/src/main/java/com/scalar/db/common/ActiveTransactionManagedDistributedTransactionManager.java | Synchronized override getScanner |
| core/src/main/java/com/scalar/db/common/AbstractTransactionManagerCrudOperableScanner.java | Added abstract manager-scanner adapter |
| core/src/main/java/com/scalar/db/common/AbstractTransactionCrudOperableScanner.java | Added abstract transaction-scanner adapter |
| core/src/main/java/com/scalar/db/common/AbstractCrudOperableScanner.java | Implemented shared scanner iterator logic |
| core/src/main/java/com/scalar/db/api/TransactionManagerCrudOperable.java | Extended API with getScanner and nested Scanner |
| core/src/main/java/com/scalar/db/api/TransactionCrudOperable.java | Extended API with getScanner and nested Scanner |
| core/src/main/java/com/scalar/db/api/CrudOperable.java | Added getScanner to base CRUD API and nested Scanner |
| core/src/integration-test/java/com/scalar/db/transaction/jdbc/JdbcTransactionIntegrationTest.java | Added placeholder tests for getScanner |
Comments suppressed due to low confidence (3)
core/src/integration-test/java/com/scalar/db/transaction/jdbc/JdbcTransactionIntegrationTest.java:46
- These placeholder tests for
getScannerhave no assertions; consider implementing actual coverage or removing them until behavior is defined.
@Disabled("Implement later")
core/src/main/java/com/scalar/db/common/DecoratedTwoPhaseCommitTransactionManager.java:115
- [nitpick] This override is boilerplate repeated across many classes; consider providing a default method in the interface to reduce duplication.
public Scanner getScanner(Scan scan) throws CrudException {
core/src/main/java/com/scalar/db/api/CrudOperable.java:61
- [nitpick] Since most implementations throw UnsupportedOperationException, you could provide a default interface implementation that throws a consistent exception, avoiding the need to add stubs everywhere.
Scanner<E> getScanner(Scan scan) throws E;
| * (e.g., a conflict error). You can retry the transaction from the beginning | ||
| * @throws CrudException if the transaction CRUD operation fails due to transient or nontransient | ||
| * faults. You can try retrying the transaction from the beginning, but the transaction may | ||
| * still fail if the cause is nontranient |
Copilot
AI
May 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word "nontranient" is a typo; it should be spelled "nontransient".
| * still fail if the cause is nontranient | |
| * still fail if the cause is nontransient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it in a separate PR.
| * (e.g., a conflict error). You can retry the transaction from the beginning | ||
| * @throws CrudException if the transaction CRUD operation fails due to transient or nontransient | ||
| * faults. You can try retrying the transaction from the beginning, but the transaction may | ||
| * still fail if the cause is nontranient |
Copilot
AI
May 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word "nontranient" is a typo; it should be spelled "nontransient".
| * still fail if the cause is nontranient | |
| * still fail if the cause is nontransient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it in a separate PR.
| throw e; | ||
| } | ||
| } | ||
|
|
Copilot
AI
May 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The stub override lacks JavaDoc. Even a brief @throws UnsupportedOperationException note would clarify the intent.
| /** | |
| * This method is not yet implemented. | |
| * | |
| * @param scan the scan operation to perform | |
| * @return nothing, as this method always throws an exception | |
| * @throws UnsupportedOperationException always, as this method is a stub | |
| */ |
| * @return a {@code Scanner} to iterate over the results | ||
| * @throws E if the transaction CRUD operation fails | ||
| */ | ||
| Scanner<E> getScanner(Scan scan) throws E; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the getScanner() method to CrudOperable.
| void mutate(List<? extends Mutation> mutations) throws E; | ||
|
|
||
| /** A scanner abstraction for iterating results. */ | ||
| interface Scanner<E extends TransactionException> extends AutoCloseable, Iterable<Result> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, added the Scanner interface to CrudOperable.
| * still fail if the cause is nontranient | ||
| */ | ||
| @Override | ||
| Scanner getScanner(Scan scan) throws CrudConflictException, CrudException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, added the getScanner() method and the Scanner interface to TransactionManagerCrudOperable.
| * still fail if the cause is nontranient | ||
| */ | ||
| @Override | ||
| Scanner getScanner(Scan scan) throws CrudConflictException, CrudException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, added the getScanner() method and the Scanner interface to TransactionCrudOperable.
| @Override | ||
| @Nonnull | ||
| public Iterator<Result> iterator() { | ||
| if (scannerIterator == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this implementation, this class should be also @NotThreadSafe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should add @NotThreadSafe to abstract classes? Actually, we basically don’t do that at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
| /** | ||
| * Returns the first result in the results. | ||
| * | ||
| * @return the first result in the results | ||
| * @throws E if the operation fails | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Javadoc was copied from com.scalar.db.api.Scanner, but I think it could be improved to be clear one() iterates over the results.
| /** | |
| * Returns the first result in the results. | |
| * | |
| * @return the first result in the results | |
| * @throws E if the operation fails | |
| */ | |
| /** | |
| * Returns the next result. | |
| * | |
| * @return an Optional containing the next result if available, or empty if no more results | |
| * @throws E if the operation fails | |
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8ae4db1. Thanks!
| /** | ||
| * Returns all the results. | ||
| * | ||
| * @return the list of {@code Result}s | ||
| * @throws E if the operation fails | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise to the comment above. I think the Javadoc should be more clear that it iterates over the results.
| /** | |
| * Returns all the results. | |
| * | |
| * @return the list of {@code Result}s | |
| * @throws E if the operation fails | |
| */ | |
| /** | |
| * Returns all remaining results. | |
| * | |
| * @return a List containing all remaining results | |
| * @throws E if the operation fails | |
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8ae4db1. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
da1cb57
into
add-scanner-api-to-transaction-abstraction
Description
This PR adds the
getScanner()method to the transaction interfaces. It does not include the actual implementations; those will be provided in subsequent PRs.Note that we are working on this feature in the
add-scanner-api-to-transaction-abstractionfeature branch, as this change may cause compile errors in dependent projects. Once all implementations are completed, we will merge the feature branch into themasterbranch.Related issues and/or PRs
N/A
Changes made
getScanner()method and theScannerinterface toCrudOperable.getScanner()method and theScannerinterface toTransactionManagerCrudOperable.getScanner()method and theScannerinterface toTransactionCrudOperable.getScanner()method.Checklist
Additional notes (optional)
N/A
Release notes
N/A